home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-16 | 13.5 KB | 520 lines | [TEXT/CWIE] |
- // Patch note for NewsWatcher 2.XX+jp1
- // Copyright (C) 1994-1996 Mizutori Tetsuya
- // NewsWatcher 2.0d17+jp1, 1994/ 5/24
- // NewsWatcher 2.0b5+jp1, 1994/ 9/15
- // NewsWatcher 2.0b13+jp1, 1994/10/22
- // NewsWatcher 2.0b24+jp1, 1995/ 1/15
- // NewsWatcher 2.0b24+jp2, 1995/ 2/ 8
- // NewsWatcher 2.0b24+jp3, 1995/ 2/22
- // NewsWatcher 2.0+jp1, 1995/ 7/14
- // NewsWatcher 2.11+jp1, 1995/11/30
- // NewsWatcher 2.12+jp1, 1996/ 2/12
- // NewsWatcher 2.13+jp1, 1996/ 6/ 6
- // NewsWatcher 2.13+jp2, 1996/ 6/20
- // NewsWatcher 2.13+jp3, 1996/ 8/27
- // NewsWatcher 2.14+jp1, 1996/11/24
- // NewsWatcher 2.15+jp1, 1996/12/16
- //
-
- /*
- The patch provides the following functions.
-
- (0) Common toolbox for the patch works. in 'myTools.{h,c}'
- The summary of contents is listed below.
-
- (1) Kanji code conversion
- In most Japanese news system, the articles and mail messages
- are (must be) coded in JIS Kanji code system. Whereas Macintosh
- system takes the Shift-JIS Kanji code system. So, the Kanji code
- conversion is required in two ways like this:
- NNTP server -> Macintosh: - related: 'net.c::MungeIn()'
- Macintosh -> NNTP or SMTP: - related: 'net.c::MungeOut()'
- NNTP server -> Mac files: - related: 'news.c::CopyArticleToFile...()'
-
- (2) Kill Latin1 conversions
- For the technical difficulties and my wish to minimize the
- patch, I have decided to rather kill the Latin-1 conversion than
- to live together with 8-bit Kanji and non-US characters.
- Kill Latin1 conversions: - related: 'charset.c::...()'
-
- (3) Wrap/UnWrap paragraphs including Kanji characters
- I have changed my mind to add Wrap/UnWrap to the patch.
- On wrapping the paragraphs, the potential break points are
- now at the boundaries of roman-words (originally), or any
- position in the Kanji-strings.
- On UnWrapping the paragraphs, the separate lines are
- concatinated with one blank character for the adjacent roman-
- words (originally), or no blanks for Kanji-strings.
- Wrap: - related: 'send.c::Wrap(), SendMessage()',
- 'message.c::DoWrap(), InsertText()'
- UnWrap: - related: 'send.c::UnWrap()',
- 'message.c::DoUnwrap()'
- */
-
-
-
- /*********************/
- /***** myTools.h *****/
- /*********************/
- -- all new ! ( a summary )
- #define MZTR_PATCH 1
-
- #define if_COUNT_MS_KANJI(n,p,pEnd)
- #define if_MS_KANJI(p,q,pEnd)
- #define if_JIS_KANJI(p,q,pEnd)
- #define if_JIS_KANJI_CHUNK(p,t,tLen,c,gFileLinePos)
-
-
-
- /*********************/
- /***** myTools.c *****/
- /*********************/
- -- all new ! ( a summary )
- /**** Kanji code conversion *****/
- Boolean IsJISKanji ( const char * p, const char * pEnd );
- Boolean IsMSKanji ( const char * p, const char * pEnd );
- Boolean IsEUCKanji ( const char * p, const char * pEnd );
-
- void EUCKanji2JIS ( const char * p, char * q );
- void JIS2EUCKanji ( const char * p, char * q );
- void MSKanji2JIS ( const char * p, char * q );
- void JIS2MSKanji ( const char * p, char * q );
-
- Boolean IsKanji ( const char * p, const char * pStart, const char * pEnd );
- long SkipOnBrace ( const char * p, const char * pStart, const char * pEnd );
-
- OSErr MyResizeHandle ( void * handle, Size len );
-
- long GetFillColumn ( void );
-
- Boolean KillCustomMessageID ( void );
-
-
- /******************/
- /***** net.c *****/
- /******************/
-
- -- line 143 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 1269 (near) in MungeOut()
- #ifdef MZTR_PATCH /* Mizutori */
-
- /* First, count the SJIS Kanji sequences */
- p = *text;
- pEnd = p + textLen;
- oldTextLen = textLen;
-
- while ( p < pEnd )
- if_COUNT_MS_KANJI(textLen,p,pEnd)
- else p++;
-
- if ( textLen == oldTextLen ) return noErr; /* including no Kanji */
-
- /* Second, resize the text size and shift the text strings forward */
- err = MySetHandleSize(text, textLen);
- if (err != noErr) return err;
- BlockMoveData(*text,*text+textLen-oldTextLen,oldTextLen);
-
- /* Third, convert Kanji code, SJIS -> JIS */
- q = *text;
- p = q + (textLen - oldTextLen);
- pEnd = p + oldTextLen;
- while ( p < pEnd )
- if_MS_KANJI(p,q,pEnd)
- else *q++ = *p++;
-
- #endif /* MZTR_PATCH */
- return noErr;
-
-
- -- line 1334 (near) in MungeIn()
- if (mungePeriods) {
- while (p < pEnd) {
- if (*p == '.' && *(p+1) == '.') {
- *q++ = '.';
- p += 2;
- }
- #ifdef MZTR_PATCH /* Mizutori */
- while (p < pEnd && (*p != CR || *(p+1) != LF))
- if_JIS_MIME(p,q,pEnd)
- else
- if_JIS_KANJI(p,q,pEnd)
- else *q++ = *p++;
- #else /* MZTR_PATCH */
- while (p < pEnd && (*p != CR || *(p+1) != LF)) *q++ = *p++;
- #endif /* MZTR_PATCH */
- *q++ = CR;
- p += 2;
- }
- } else {
- while (p < pEnd) {
- #ifdef MZTR_PATCH /* Mizutori */
- if_JIS_MIME(p,q,pEnd)
- else
- if_JIS_KANJI(p,q,pEnd)
- else
- #endif /* MZTR_PATCH */
- if (*p == CR && *(p+1) == LF) {
- *q++ = CR;
- p += 2;
- } else {
- *q++ = *p++;
- }
- }
- }
-
-
-
- /******************/
- /***** news.c *****/
- /******************/
-
- -- line 33 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 619 (near) in CopyArticleToFileChunkFunction()
- #ifdef MZTR_PATCH /* Mizutori */
- static Boolean gInKanjiSequence = false;
- static Boolean gEscapeKanjiIn = false;
- static Boolean gEscapeKanjiOut = false;
- static Ptr gMimeStart = nil;
- #endif /* MZTR_PATCH */
-
-
- -- line 675 (near) in CopyArticleToFileChunkFunction()
- #ifdef MZTR_PATCH /* Mizutori */
- } else if_JIS_MIME_CHUNK(p,t,tLen,c,x->fileLinePos)
- else if_JIS_KANJI_CHUNK(p,t,tLen,c,x->fileLinePos)
- else if (c >= ' ' || c == CR || c == FF || c < 0 || c==ESC) {
- #else /* MZTR_PATCH */
- } else if (c >= ' ' || c == CR || c == FF || c < 0) {
- #endif /* MZTR_PATCH */
-
-
-
- /******************/
- /**** charset.c ***/
- /******************/
-
- -- line 20 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 53 (near) in MapLatin1ToMacPtr()
- #ifdef MZTR_PATCH /* Mizutori */
- return false;
- #endif /* MZTR_PATCH */
-
-
- -- line 120 (near) in MapLatin1ToMacStr()
- #ifdef MZTR_PATCH /* Mizutori */
- *q = *p;
- #else /* MZTR_PATCH */
- *q = table[*p];
- #endif /* MZTR_PATCH */
-
-
- -- line 149 (near) in MapMacToLatin1Ptr()
- #ifdef MZTR_PATCH /* Mizutori */
- return false;
- #endif /* MZTR_PATCH */
-
-
- /***** patch for sorting Kanji Subject *****/
-
- /********************/
- /***** thread.c *****/
- /********************/
-
- -- line 25 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 267 (near) in InitSortInfo()
- while (*x != 0) {
- #ifdef MZTR_PATCH /* Mizutori */
- if ( IsKanji(x,x,x+2) ) {
- *canon++ = *x++;
- *canon++ = *x++;
- } else
- #endif /* MZTR_PATCH */
-
-
-
- /***** patch for No Extra space around Kanji strings *****/
-
- /********************/
- /***** teutil.c *****/
- /********************/
-
- -- line 19 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 180 (near) in IsWordStart()
- #ifdef MZTR_PATCH /* Mizutori */
- if ( IsKanji(str+offset,str,str+len) ) return false;
- #endif /* MZTR_PATCH */
-
-
- -- line 212 (near) in IsWordEnd()
- #ifdef MZTR_PATCH /* Mizutori */
- if ( IsKanji(str+offset-2,str,str+len) ) return false;
- #endif /* MZTR_PATCH */
-
-
-
- /***** patch for Wrap/UnWrap paragraphs *****/
-
- /******************/
- /***** send.h *****/
- /******************/
- // void Wrap (Handle text, long start, long end);
- // void UnWrap (Handle text, long start, long end);
- long Wrap (Handle text, long start, long end); /* Mizutori */
- long UnWrap (Handle text, long start, long end); /* Mizutori */
-
-
- /******************/
- /***** send.c *****/
- /******************/
-
- -- line 28 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 48 (near) in Wrap()
- #ifdef MZTR_PATCH /* Mizutori */
- long Wrap (Handle text, long start, long end)
- #else /* MZTR_PATCH */
- void Wrap (Handle text, long start, long end)
- #endif /* MZTR_PATCH */
- {
- char *p, *pEnd, *q, *lastSpace;
- #ifdef MZTR_PATCH /* Mizutori */
- long gFillColumn = GetFillColumn(); // typically 74
- #endif /* MZTR_PATCH */
-
- p = *text + start;
- pEnd = *text + end;
- while (p < pEnd) {
- q = p;
- while (q < pEnd && *q != CR) q++;
- #ifdef MZTR_PATCH /* Mizutori */
- if (q - p > gFillColumn+6) {
- #else /* MZTR_PATCH */
- if (q - p > 80) {
- #endif /* MZTR_PATCH */
- q = p;
- lastSpace = 0;
- while (true) {
- #ifdef MZTR_PATCH /* Mizutori */
- if ( IsKanji(q,*text+start,pEnd) ) {
- long k;
- q++;
- while ( (k=SkipOnBrace(q+1,*text+start,pEnd)) > 0 ) q += k;
- while ((q+1) < pEnd && *(q+1) == ' ') q++;
- if (lastSpace != 0 && lastSpace - p <= (gFillColumn-2) && q - p >= (gFillColumn+1)) lastSpace = q;
- // if (lastSpace != 0 && lastSpace - p <= 72 && q - p >= 75) lastSpace = q;
- } else {
- while (q < pEnd && *q != ' ' && *q != CR && !IsKanji(q,*text+start,pEnd)) q++;
- if ( IsKanji(q,*text+start,pEnd) ) q--;
- }
- #else /* MZTR_PATCH */
- while (q < pEnd && *q != ' ' && *q != CR) q++;
- #endif /* MZTR_PATCH */
- if (q < pEnd && *q == ' ') {
- while (q < pEnd && *q == ' ') q++;
- q--;
- }
- #ifdef MZTR_PATCH /* Mizutori */
- if (q - p >= (gFillColumn+1) && lastSpace != 0) {
- #else /* MZTR_PATCH */
- if (q - p >= 75 && lastSpace != 0) {
- #endif /* MZTR_PATCH */
- #ifdef MZTR_PATCH /* Mizutori */
- lastSpace++;
- if ( *lastSpace != CR ) {
- long pX, pEndX, qX, lastSpaceX;
- long len = MyGetHandleSize(text);
- pX = p - *text; pEndX = pEnd - *text; qX = q - *text; lastSpaceX = lastSpace - *text;
- MyResizeHandle(text, len+1);
- p = *text + pX; pEnd = *text + pEndX; q = *text + qX; lastSpace = *text + lastSpaceX;
- BlockMoveData(lastSpace,lastSpace+1,len - (lastSpace - *text));
- q++; // q = lastSpace + 1;
- pEnd++;
- }
- #endif /* MZTR_PATCH */
- *lastSpace = CR;
- p = lastSpace + 1;
- lastSpace = 0;
- }
- if (q >= pEnd || *q == CR) break;
- lastSpace = q;
- q++;
- }
- }
- p = q+1;
- }
- #ifdef MZTR_PATCH /* Mizutori */
- return (long) ( pEnd - *text - end );
- #endif /* MZTR_PATCH */
- }
-
-
- -- line 137 (near) in UnWrap()
- #ifdef MZTR_PATCH /* Mizutori */
- long UnWrap (Handle text, long start, long end)
- #else /* MZTR_PATCH */
- void UnWrap (Handle text, long start, long end)
- #endif /* MZTR_PATCH */
- {
- char *p, *pEnd;
-
- p = *text + start;
- pEnd = *text + end;
- while (p < pEnd) {
- while (p < pEnd && *p != CR) p++;
- p++;
- if (p < pEnd) {
- if (*p == ' ' || *p == '\t') continue;
- if (*p == CR) {
- while (p < pEnd && *p == CR) p++;
- continue;
- }
- #ifdef MZTR_PATCH /* Mizutori */
- if ( *(p-2) == ' ' || *(p-2) == '\t' ||
- ( IsKanji(p-3,*text+start,pEnd) || IsKanji(p,*text+start,pEnd) ) ) {
- // ( IsKanji(p-3,*text+start,pEnd) && IsKanji(p,*text+start,pEnd) ) ) {
- long pX, pEndX;
- long len = MyGetHandleSize(text);
- BlockMoveData(p,p-1,len - (p - *text));
- pX = p - *text; pEndX = pEnd - *text;
- MyResizeHandle(text, len-1);
- p = *text + pX; pEnd = *text + pEndX;
- pEnd--;
- } else
- *(p-1) = ' ';
- #else /* MZTR_PATCH */
- *(p-1) = ' ';
- #endif /* MZTR_PATCH */
- }
- }
- #ifdef MZTR_PATCH /* Mizutori */
- return - (long) ( *text + end - pEnd );
- #endif /* MZTR_PATCH */
- }
-
-
- -- line 742 (near) in SendMessage()
- #ifdef MZTR_PATCH /* Mizutori */
- if ((**info).wrapOnSend) textLen += Wrap(text, 0, textLen);
- #else /* MZTR_PATCH */
- if ((**info).wrapOnSend) Wrap(text, 0, textLen);
- #endif /* MZTR_PATCH */
-
-
- /*********************/
- /***** message.c *****/
- /*********************/
-
- -- line 46 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 1588 (near) in InsertText()
- if (q - p + quoteStringLen > 80)
- #ifdef MZTR_PATCH /* Mizutori */
- {
- long pX, pEndX, qX;
- long addLen;
- pX = p - (unsigned char*)*newText; pEndX = pEnd - (unsigned char*)*newText; qX = q - (unsigned char*)*newText;
- addLen = Wrap(newText, p - (unsigned char*)*newText, q - (unsigned char*)*newText);
- p = (unsigned char*)*newText + pX; pEnd = (unsigned char*)*newText + pEndX; q = (unsigned char*)*newText + qX;
- q += addLen;
- pEnd += addLen;
- newLen += addLen;
- }
- #else /* MZTR_PATCH */
- Wrap(newText, p - (unsigned char*)*newText, q - (unsigned char*)*newText);
- #endif /* MZTR_PATCH */
-
-
- -- line 4498 (near) in DoWrap()
- #ifdef MZTR_PATCH /* Mizutori */
- (**edit).selEnd += Wrap((**edit).hText, (**edit).selStart, (**edit).selEnd);
- #else /* MZTR_PATCH */
- Wrap((**edit).hText, (**edit).selStart, (**edit).selEnd);
- #endif /* MZTR_PATCH */
-
-
- -- line 4533 (near) in DoUnwrap()
- #ifdef MZTR_PATCH /* Mizutori */
- (**edit).selEnd += UnWrap((**edit).hText, (**edit).selStart, (**edit).selEnd);
- #else /* MZTR_PATCH */
- UnWrap((**edit).hText, (**edit).selStart, (**edit).selEnd);
- #endif /* MZTR_PATCH */
-
-
- /***** patch for Caret step by Arrow key *****/
-
- /********************/
- /***** teutil.c *****/
- /********************/
-
- -- line 19 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 826 (near) in GetOffsetGivenPixelsFromBol()
- while (result < eol && TextWidth(*hText, bol, result - bol) < pixelsFromBol) result++;
- #ifdef MZTR_PATCH /* Mizutori */
- if ( IsKanji(*hText+result-1,*hText+bol,*hText+eol) ) result++;
- #endif /* MZTR_PATCH */
-
-
- -- line 987 (near) in TEArrowKey()
- #ifdef MZTR_PATCH /* Mizutori */
- if (shift || selStart == selEnd) { offset--;
- if ( IsKanji(*hText+offset-1,*hText,*hText+teLength) ) offset--; }
- #else /* MZTR_PATCH */
- if (shift || selStart == selEnd) offset--;
- #endif /* MZTR_PATCH */
-
-
- -- line 996 (near) in TEArrowKey()
- #ifdef MZTR_PATCH /* Mizutori */
- if (shift || selStart == selEnd) { offset++;
- if ( IsKanji(*hText+offset-1,*hText,*hText+teLength) ) offset++; }
- #else /* MZTR_PATCH */
- if (shift || selStart == selEnd) offset++;
- #endif /* MZTR_PATCH */
-
-
-
- /***** patch for Kill Custom MessageID *****/
-
- /********************/
- /***** header.c *****/
- /********************/
-
- -- line 25 (near)
- #include "myTools.h" /* Mizutori */
-
-
- -- line 301 (near) in MakeMsgIdHeader()
- sprintf(id, "<%.*s-%.2d%.2d%.2d%.2d%.2d%.2d%.4d@%s>",
- len, gPrefs.emailAddress, dtRec.day, dtRec.month,
- dtRec.year%100, dtRec.hour, dtRec.minute, dtRec.second,
- uniqueWithinSecond, hostName);
- #ifdef MZTR_PATCH /* Mizutori */
- if ( KillCustomMessageID() ) *id = 0;
- #endif /* MZTR_PATCH */
- return noErr;
-
- --
- mizutori@ai.rcast.u-tokyo.ac.jp
-